{% extends 'base.html' %}
{% load humanize %}
{% block page-content %}
{% include 'nav_cat_bar.html' %}

<link href="/static/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">
<link href="/static/css/plugins/dataTables/dataTables.responsive.css" rel="stylesheet">
<link href="/static/css/plugins/dataTables/dataTables.tableTools.min.css" rel="stylesheet">

<div class="wrapper wrapper-content">
    <div class="row">
        <form id="contents_form" name="contents_form" enctype="multipart/form-data">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5><font color="green">请输入指令</font></h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="#">未启用 1</a>
                            </li>
                            <li><a href="#">未启用 2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="row">
                        {% if log %}
                        <div class="alert alert-success text-center">{{ log }}</div>
                        {% endif %}
                        {% if error %}
                        <div class="alert alert-danger text-center">{{ error }}</div>
                        {% endif %}
                        <div class="col-sm-12 m-b-xs">
                            <h5 class="tag-title"><font style="color: red">注:危险指令请误输入</font></h5>
                            <div class="pull-left input-group col-sm-10 has-success">
                                <div class="input-group-addon">root:~#</div>
                                <input type="text" name="bash_cmd" class="form-control" placeholder="请输入BASH命令">
                            </div>
                            <div class="container col-sm-2">
                                <button style="height: 34px" type="submit" class="btn btn-primary btn-block dim"  form="contents_form" formmethod="post" formaction="{% url 'exec_cmds_process' %}?project={{project}}" onclick="return confirm('确认执行吗？')">
                                <span class="bold">开始执行</span></button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>选择服务器</h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li><a href="#">未启用 1</a>
                            </li>
                            <li><a href="#">未启用 2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="row">
                    <div class="col-sm-12 m-b-xs">
                        {% for pro in pro_info %}
                            <a type="button" class="btn btn-primary btn-sm" href="{% url 'exec_cmds' %}?project={{pro.mini_name}}">{{pro.name}}</a>
                        {% endfor %}
                    </div>
                    </div>

                    <table class="table table-striped table-bordered table-hover dataTables-example">
                          <thead>
                            <th class="text-center"></th>
                            <th class="text-center">项目</th>
                            <th class="text-center">地区</th>
                            <th class="text-center">平台</th>
                            <th class="text-center">操作系统</th>
                            <th class="text-center">IP</th>
                            <th class="text-center">端口</th>
                            <th class="text-center">服务器用途</th>
                            <th class="text-center">备注</th>
                          </thead>
                          <tbody>
                            {% for num in host_info %}
                              <tr class="text-center">
                                <td >{{forloop.counter}}.<input type="checkbox" class="i-checks" name="host" value={{num.p_ip}}></td>
                                <td>{{num.project.name}}</td>
                                <td>{{num.area.area_name}}</td>
                                <td>{{num.platform.plat_name}}</td>
                                <td>{{num.os_type}}</td>
                                <td>{{num.p_ip}}</td>
                                <td>{{num.port}}</td>
                                <td>{% for use in num.use.all %} {{use}}{% endfor %}</td>
                                <td>{{num.commit}}</td>
                              </tr>
                            {% endfor %}
                          </tbody>
                        </table>
                        <input id="checkall" type="checkbox" class="i-checks" name="checkall" value="checkall" data-editable='false' onclick="check_all('contents_form')">全选/全不选
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<script src="/static/js/plugins/dataTables/jquery.dataTables.js"></script>
<script src="/static/js/plugins/dataTables/dataTables.bootstrap.js"></script>
<script src="/static/js/plugins/dataTables/dataTables.responsive.js"></script>
<script src="/static/js/plugins/dataTables/dataTables.tableTools.min.js"></script>

<script type="text/javascript">
$(document).ready(function() {
            $('.dataTables-example').dataTable({
                responsive: true,
                "dom": 'T<"clear">lfrtip',
                "iDisplayLength":10,
                "tableTools": {
                    "aButtons":["copy","xls",'print'],
                    "sSwfPath": "/static/js/plugins/dataTables/swf/copy_csv_xls_pdf.swf"
                }
            });
        });

</script>

{%endblock%}